import cv2
import numpy as np

img = cv2.imread('E:\\py\\camHumDetect\\img\\testzb.png')
#rows,cols,ch = img.shape
#变换前4点坐标
#pts1 = np.float32([[721,357],[883,387],[652,439],[830,478]])
#变换后4点坐标
#pts2 = np.float32([[830,373],[830,483],[720,373],[720,483]])
#缩小10倍，110px->11px
#pts2 = np.float32([[830,373],[830,384],[819,373],[819,384]])
#平移-500px，110px->11px
#pts2 = np.float32([[330,373],[330,483],[220,373],[220,483]])
#计算变换矩阵
#M = cv2.getPerspectiveTransform(pts1,pts2)
#应用到图像
#TODO:图像位置调整


#zb
#cap = cv2.VideoCapture("rtsp://admin:admin123@192.168.1.164:554/h264/ch38/sub/av_stream")
pts1 = np.float32([[106.7,185],[168.85,206],[63.25,230],[129.25,261]])
pts2 = np.float32([[330,164],[398,155],[328,75],[395,90]])
M = cv2.getPerspectiveTransform(pts1,pts2)
rows,cols,ch = img.shape
print(M)

dst = cv2.warpPerspective(img,M,(cols,rows),cv2.INTER_LINEAR)
# cv2.imwrite('E:\\py\\camHumDetect\\test3suo.png', dst)
cv2.imshow('image',dst)
cv2.waitKey(0)